<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册</title>
    <script>
        function doCheck() {
            let loginName = document.querySelector("input[name=loginName]").value;
            if(!loginName || !loginName.trim()) {
                alert("登录名不能为空");
                return false;
            }

            let password = document.querySelector("input[name=password]").value;
            let rePassword = document.querySelector("input[name=rePassword]").value;
            if(password != rePassword){
                alert("两次输入的密码不一致");
                return false;
            }
            return true;
        }
    </script>
</head>
<body>
    <h2>注册</h2>
    <?php
    $msg = $_REQUEST["msg"];
    ?>
    <div style="height: 30px;color: red;font-size: 24px;" ><?= $msg ?></div>
    <form action="reg.php" method="post" onsubmit="return doCheck()">
        <div>
            <label>登录名:<input type="text" name="loginName"></label>
        </div>
        <div>
            <label>密码:<input type="password" name="password"></label>
        </div>
        <div>
            <label>确认密码:<input type="password" name="rePassword"></label>
        </div>
        <div>
            <label>手机号:<input type="text" name="phone"></label>
        </div>
        <div>
            <input type="submit" value="注册">
        </div>
    </form>
</body>
</html>